Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lock service API #50

Merged
merged 2 commits into from
Feb 2, 2019
Merged

Conversation

dariko
Copy link
Contributor

@dariko dariko commented Feb 1, 2019

This PR adds support for the lock service API:
https://github.com/etcd-io/etcd/blob/master/Documentation/dev-guide/api_concurrency_reference_v3.md#service-lock-etcdserverapiv3lockv3lockpbv3lockproto
https://github.com/etcd-io/etcd/blob/master/etcdserver/api/v3lock/v3lockpb/v3lock.proto

Two methods are added to the client via the LockAPI class:

  • lock(self, name, lease=0)
    Lock acquires a distributed shared lock on a given named lock.
    On success, it will return a unique key that exists so long as
    the lock is held by the caller. This key can be used in
    conjunction with transactions to safely ensure updates to etcd
    only occur while holding lock ownership. The lock is held until
    Unlock is called on the key or the lease associate with the
    owner expires.
    
  • unlock(self, key):
    Unlock takes a key returned by Lock and releases the hold on
    lock. The next Lock caller waiting for the lock will then be
    woken up and given ownership of the lock.
    

@codecov
Copy link

codecov bot commented Feb 1, 2019

Codecov Report

Merging #50 into master will increase coverage by 0.14%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   90.99%   91.13%   +0.14%     
==========================================
  Files          45       47       +2     
  Lines        2631     2674      +43     
  Branches      273      273              
==========================================
+ Hits         2394     2437      +43     
  Misses        145      145              
  Partials       92       92
Impacted Files Coverage Δ
etcd3/apis/lock.py 100% <100%> (ø)
etcd3/apis/__init__.py 100% <100%> (ø) ⬆️
etcd3/baseclient.py 92.68% <100%> (+0.09%) ⬆️
tests/test_lock_apis.py 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aceada8...babc64f. Read the comment docs.

@Revolution1
Copy link
Owner

Thank you for your contribution!

Seems I forgot some apis (lock and election) in the early releases 😢

@dariko
Copy link
Contributor Author

dariko commented Feb 1, 2019

You're welcome! 😄

@Revolution1 Revolution1 merged commit f3f3c1b into Revolution1:master Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants